<template>
  <div class="profit">
    <div class="profit-bg">
    	<div class="tody-profit">
    		<span><strong>{{  Number(todayProfit || 0).toFixed(2)}}</strong></span>
    		<span class="tody-text">今日收益</span>
    	</div>
    	<div class="all-profit"><span class="all">累计:</span><i class="fa fa-rmb"></i><span>{{Number(allProfit || 0).toFixed(2)}}</span></div>
    </div>

    <!--<div class="jump">-->
      <!--<el-row class="jump-list">-->
        <!--<el-col :span="6"><div class="grid-content item02" @click="commission"><span>提成</span></div></el-col>-->
        <!--<el-col :span="6"><div class="grid-content item04" @click="bought"><span>会员已购信息</span></div></el-col>-->
      <!--</el-row>-->
    <!--</div>-->

  </div>

</template>

<script>
  import moment from 'moment';
  export default {
    name:'keepAilve',
      data: function () {

          return {
             todayProfit: '',
             allProfit: '',
             loading: false
          }
      },
      created: function () {
          this.$$("#content").scrollTop(0)
          this.loading = true;
          let self = this;
          let currentDate = new Date();
          let args ={
              "bizDate": moment(currentDate).format('YYYY-MM-DD')
          };
          console.log(args);

          this.$axioxs({
               method: 'get',
               url: '/Income/?bizDate='+args.bizDate
            })
          .then(function (res) {
              console.log(JSON.stringify(res.data));
              console.log(res.data);
              if(res.data.records[0]){
                if(res.data.records[0].received){
                  self.todayProfit = res.data.records[0].received;
                }else {
                  self.todayProfit = 0;
                }

              }else {
                self.todayProfit = 0;
              }

              self.loading = false;

          })
          .catch(function (error) {
            console.log(error);
            self.loading = true;
          });

            this.$axioxs({
                 method: 'get',
                 url: '/Income/all'
            })
            .then(function (res) {
                console.log(JSON.stringify(res.data));
                console.log(res.data);
                self.allProfit = res.data.sum;
                self.loading = false;
            })
            .catch(function (error) {
              console.log(error);
              self.loading = true;
            });
      },
      methods: {
        handleClick(tab, event) {
          console.log(tab, event);
        },
        commission: function () {
          console.log("==========>commission提成");
          this.$router.push({
            path:'/report'
          });

        },
        bought: function () {
          console.log("==========>bought已购");

          this.$router.push({
            path:'/bought'
          });

        }
      }

  }
</script>

<style scoped>
.item02, .item04{
  border-right: 1px solid #ccc;
  padding-bottom: 5px;
}
</style>
